<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Console.Haskeline.Backend.WCWidth</span><span class="hs-special">(</span><span>
</span><span id="line-2"></span><span>                            </span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#gsWidth"><span class="hs-identifier">gsWidth</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-3"></span><span>                            </span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth"><span class="hs-identifier">splitAtWidth</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-4"></span><span>                            </span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#takeWidth"><span class="hs-identifier">takeWidth</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-5"></span><span>                            </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Certain characters are &quot;wide&quot;, i.e. take up two spaces in the terminal.</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- This module wraps the necessary foreign routines, and also provides some convenience</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- functions for width-breaking code.</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html"><span class="hs-identifier">System.Console.Haskeline.LineState</span></a></span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier">foldl'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#"><span class="hs-identifier">Foreign.C.Types</span></a></span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span id="haskeline_mk_wcwidth"><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#haskeline_mk_wcwidth"><span class="hs-identifier hs-var">haskeline_mk_wcwidth</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#wcwidth"><span class="hs-identifier hs-type">wcwidth</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-19"></span><span id="wcwidth"><span class="annot"><span class="annottext">wcwidth :: Char -&gt; Int
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#wcwidth"><span class="hs-identifier hs-var hs-var">wcwidth</span></a></span></span><span> </span><span id="local-6989586621679092370"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679092370"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#haskeline_mk_wcwidth"><span class="hs-identifier hs-var">haskeline_mk_wcwidth</span></a></span><span> </span><span class="annot"><span class="annottext">(CInt -&gt; CInt) -&gt; CInt -&gt; CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a. Enum a =&gt; Int -&gt; a
</span><a href="../../base/src/GHC.Enum.html#toEnum"><span class="hs-identifier hs-var">toEnum</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CInt) -&gt; Int -&gt; CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="../../base/src/GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679092370"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-20"></span><span>                </span><span class="hs-glyph">-</span><span class="hs-number">1</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-comment">-- Control characters have zero width.  (Used by the</span><span>
</span><span id="line-21"></span><span>                        </span><span class="hs-comment">-- &quot;\SOH...\STX&quot; hack in LineState.stringToGraphemes.)</span><span>
</span><span id="line-22"></span><span>                </span><span id="local-6989586621679092367"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679092367"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679092367"><span class="hs-identifier hs-var">w</span></a></span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#gWidth"><span class="hs-identifier hs-type">gWidth</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-25"></span><span id="gWidth"><span class="annot"><span class="annottext">gWidth :: Grapheme -&gt; Int
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#gWidth"><span class="hs-identifier hs-var hs-var">gWidth</span></a></span></span><span> </span><span id="local-6989586621679092365"><span class="annot"><span class="annottext">Grapheme
</span><a href="#local-6989586621679092365"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#wcwidth"><span class="hs-identifier hs-var">wcwidth</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Grapheme -&gt; Char
</span><a href="System.Console.Haskeline.LineState.html#baseChar"><span class="hs-identifier hs-var">baseChar</span></a></span><span> </span><span class="annot"><span class="annottext">Grapheme
</span><a href="#local-6989586621679092365"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#gsWidth"><span class="hs-identifier hs-type">gsWidth</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-28"></span><span id="gsWidth"><span class="annot"><span class="annottext">gsWidth :: [Grapheme] -&gt; Int
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#gsWidth"><span class="hs-identifier hs-var hs-var">gsWidth</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Int -&gt; Int) -&gt; Int -&gt; [Int] -&gt; Int
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">(+)</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">([Int] -&gt; Int) -&gt; ([Grapheme] -&gt; [Int]) -&gt; [Grapheme] -&gt; Int
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Grapheme -&gt; Int) -&gt; [Grapheme] -&gt; [Int]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Grapheme -&gt; Int
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#gWidth"><span class="hs-identifier hs-var">gWidth</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-comment">-- | Split off the maximal list which is no more than the given width.</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- returns the width of that list.</span><span>
</span><span id="line-32"></span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth"><span class="hs-identifier hs-type">splitAtWidth</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span id="splitAtWidth"><span class="annot"><span class="annottext">splitAtWidth :: Int -&gt; [Grapheme] -&gt; ([Grapheme], [Grapheme], Int)
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth"><span class="hs-identifier hs-var hs-var">splitAtWidth</span></a></span></span><span> </span><span id="local-6989586621679092361"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092361"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679092360"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092360"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Grapheme] -&gt; ([Grapheme], [Grapheme], Int)
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth%27"><span class="hs-identifier hs-var">splitAtWidth'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092361"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092360"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-34"></span><span>                        </span><span class="hs-special">(</span><span id="local-6989586621679092358"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092358"><span class="hs-identifier hs-var">this</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679092357"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092357"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679092356"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092356"><span class="hs-identifier hs-var">remaining</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092358"><span class="hs-identifier hs-var">this</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092357"><span class="hs-identifier hs-var">rest</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092361"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092356"><span class="hs-identifier hs-var">remaining</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-comment">-- Returns the amount of unused space in the line.</span><span>
</span><span id="line-37"></span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth%27"><span class="hs-identifier hs-type">splitAtWidth'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span id="splitAtWidth%27"><span class="annot"><span class="annottext">splitAtWidth' :: Int -&gt; [Grapheme] -&gt; ([Grapheme], [Grapheme], Int)
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth%27"><span class="hs-identifier hs-var hs-var">splitAtWidth'</span></a></span></span><span> </span><span id="local-6989586621679092355"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092355"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092355"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth%27"><span class="hs-identifier hs-var">splitAtWidth'</span></a></span><span> </span><span id="local-6989586621679092354"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092354"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679092353"><span class="annot"><span class="annottext">Grapheme
</span><a href="#local-6989586621679092353"><span class="hs-identifier hs-var">g</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679092352"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092352"><span class="hs-identifier hs-var">gs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092351"><span class="hs-identifier hs-var">gw</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092354"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="annottext">Grapheme
</span><a href="#local-6989586621679092353"><span class="hs-identifier hs-var">g</span></a></span><span class="annot"><span class="annottext">Grapheme -&gt; [Grapheme] -&gt; [Grapheme]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092352"><span class="hs-identifier hs-var">gs</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092354"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Grapheme
</span><a href="#local-6989586621679092353"><span class="hs-identifier hs-var">g</span></a></span><span class="annot"><span class="annottext">Grapheme -&gt; [Grapheme] -&gt; [Grapheme]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092349"><span class="hs-identifier hs-var">gs'</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092348"><span class="hs-identifier hs-var">gs''</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092347"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-43"></span><span>    </span><span id="local-6989586621679092351"><span class="annot"><span class="annottext">gw :: Int
</span><a href="#local-6989586621679092351"><span class="hs-identifier hs-var hs-var">gw</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Grapheme -&gt; Int
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#gWidth"><span class="hs-identifier hs-var">gWidth</span></a></span><span> </span><span class="annot"><span class="annottext">Grapheme
</span><a href="#local-6989586621679092353"><span class="hs-identifier hs-var">g</span></a></span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679092349"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092349"><span class="hs-identifier hs-var">gs'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679092348"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092348"><span class="hs-identifier hs-var">gs''</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679092347"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092347"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Grapheme] -&gt; ([Grapheme], [Grapheme], Int)
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth%27"><span class="hs-identifier hs-var">splitAtWidth'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092354"><span class="hs-identifier hs-var">w</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092351"><span class="hs-identifier hs-var">gw</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092352"><span class="hs-identifier hs-var">gs</span></a></span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-comment">-- Returns the longest prefix less than or equal to the given width</span><span>
</span><span id="line-47"></span><span class="hs-comment">-- plus the width of that list.</span><span>
</span><span id="line-48"></span><span class="annot"><a href="System.Console.Haskeline.Backend.WCWidth.html#takeWidth"><span class="hs-identifier hs-type">takeWidth</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.LineState.html#Grapheme"><span class="hs-identifier hs-type">Grapheme</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span id="takeWidth"><span class="annot"><span class="annottext">takeWidth :: Int -&gt; [Grapheme] -&gt; ([Grapheme], Int)
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#takeWidth"><span class="hs-identifier hs-var hs-var">takeWidth</span></a></span></span><span> </span><span id="local-6989586621679092345"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092345"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679092344"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092344"><span class="hs-identifier hs-var">gs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Grapheme] -&gt; ([Grapheme], [Grapheme], Int)
</span><a href="System.Console.Haskeline.Backend.WCWidth.html#splitAtWidth"><span class="hs-identifier hs-var">splitAtWidth</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092345"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092344"><span class="hs-identifier hs-var">gs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-50"></span><span>                    </span><span class="hs-special">(</span><span id="local-6989586621679092343"><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092343"><span class="hs-identifier hs-var">gs'</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Grapheme]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679092342"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092342"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Grapheme]
</span><a href="#local-6989586621679092343"><span class="hs-identifier hs-var">gs'</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679092342"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span></pre></body></html>